<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="../css/common.css?01_24" />
		<link rel="stylesheet" type="text/css" href="../css/templet.css?01_24" />
		<link rel="stylesheet" type="text/css" href="../fonts/font-awesome.min.css?01_24" />
		<link rel="stylesheet" type="text/css" href="../mui/css/mui.css?01_24" />

		<!--公共js-->
		<script type="text/javascript" src="../common/js/jquery.js?01_24"></script>
		<script type="text/javascript" src="../common/js/fastclick.js?01_24"></script>
		<script type="text/javascript" src="../common/js/common.js?01_24"></script>
		<script type="text/javascript" src="../common/js/my_common.js?01_24"></script>
		<script type="text/javascript" src="../common/js/main.js?01_24"></script>
		<script type="text/javascript" src="../common/js/app.js?01_24"></script>
		<!--插件-->
		<script type="text/javascript" src="../common/js/vue.min.js?01_24"></script>
		<script type="text/javascript" src="../common/js/mui.min.js?01_24"></script>
	</head>

	<body>
		<header class="bg-red9 fff f-20 pad-t-10 pad-b-10 pad-l-10 pad-r-10">
			<div class="pa back" onclick="cli_backpre()">
				<a></a>
			</div>
			<div class="center" data-l="1389"></div>
		</header>
		<div id="app" v-cloak>
			<div class="wrap_body write_off_success pad-t-45">
				<div class="content">
					<!--已经核销-->

					<div class="have_cancel can_cancel pad-l-10 pad-r-10 pad-t-15">
						<div class="wrap bg-fff f-16 pr">
							<span class="bg-green fff f-10 pad-2 status pa pad-l-5 pad-r-5" v-if="couponStatus == 1">{{b_lg[1360]}}</span>
							<span class="bg-grayE9 fff f-10 pad-2 status pa pad-l-5 pad-r-5" v-else-if="couponStatus == 2">{{b_lg[1146]}}</span>
							<span class="bg-yellow fff f-10 pad-2 status pa pad-l-5 pad-r-5" v-else-if="couponStatus == 3">{{b_lg[1527]}}</span>
							<span class="bg-red9 fff f-10 pad-2 status pa pad-l-5 pad-r-5" v-else-if="couponStatus == 4">{{b_lg[1528]}}</span>
							<div class="fiex top pad-10">
								<div class="pad-l-10 pad-r-10 red9 f-26" v-if="amount>0">{{amount}}</div>
								<div class="pad-l-10 pad-r-10 red9 f-26" v-else=""><span v-if="languageStyle == 'zh'">{{100-discount}}<span class="f-20">% off</span></span><span v-else>{{100-discount}}% <span class="f-16">off</span></span></div>
								<div class="pad-l-10">

									<div class="f-16">{{name}}</div>
									<p class="red9 f-14">{{b_lg[1529]}} {{condition}} RM</p>
									<p class="f-14 ccc"><span>{{b_lg[1139]}}：</span><span>{{begin_time}}</span><span> - </span><span>{{end_time}}</span></p>

								</div>
							</div>
							<div class="f-14">
								<div class="pad-5">
									<p>{{b_lg[1140]}}</p>
									<p class="ccc f-13 pad-t-1">{{content}}</p>
								</div>

								<div class="pad-l-5 pad-r-5 pad-b-5">
									<p>{{b_lg[1141]}}</p>
									<p class="ccc f-13 pad-t-1">{{shop_list_name}}</p>
								</div>
							</div>

						</div>
						<div class="bank30"></div>
						<div class="wrap bg-fff fiex pad-10">
							<div>
								<img v-if=" headimgurl!='' " id="image" :src="oss+headimgurl" class="icon" />
								<img v-else id="image" alt="用户头像" :src="con_img" class="icon ccc" onerror="lod(this)" />
								<!--<img src="../images/accountSetting/icon.png" alt="" class="icon"/>-->
							</div>
							<!--username为空时，为游客-->
							<div class="pad-l-20" v-if="username == ''">User：{{id}}</div>
							<!--username不为空时，为用户，显示昵称和手机号-->
							<div class="pad-l-20" v-else>
								<!--is_vip为1时，显示小图标-->
								<div>{{nickname}} <span class="vip" v-show="is_vip == 1"></span></div>
								<div>{{username}}</div>
							</div>
						</div>
						<div class="bank10"></div>
					</div>
					<p class="center mag-t-45">
						<a class="pad-l-65 pad-r-65 bg-red9 fff pad-t-15 pad-b-15 btn" @click="cancelCoupon" v-show="couponStatus == 1">{{b_lg[1530]}}</a>
					</p>

				</div>

			</div>

			<!--核销成功的弹窗-->
			<div class="mask bg-000 pa" @click="hide" v-show="status == 1">
				<div class="pad-l-40 pad-r-40 pad-t-200">
					<div class="bg-fff wrap pr center pad-t-50 pad-b-40">
						<p class="success pa"></p>
						<p class="f-16">{{b_lg[1531]}}</p>
					</div>
				</div>
			</div>
		</div>

	</body>
	<script type="text/javascript">
		var app = null;
		var getSn = getQueryString("sn");
		var getID = getQueryString("id");
		//id为1时，是从会员卡记录进来的
		//id为2时，是从扫码页进来的
		function cli_backpre(){
			app.backpre()
		}
		function plusReady() {}
		if(window.plus) {
			plusReady();
		} else {
			document.addEventListener('plusready', plusReady, false);
		}

		// 关闭自身窗口
		function closeme() {
			var ws = plus.webview.currentWebview();

			plus.webview.close(ws);
		}
		// 关闭父层窗口
		function closepre() {
			var preUrl = plus.webview.currentWebview().opener();
			var ws = plus.webview.currentWebview();

			plus.webview.close(ws);
			plus.webview.close(preUrl);
		}

		function fun1() {
			if(getID==2){ //从扫码页面进入的关闭扫码页面
				var preUrl = plus.webview.currentWebview().opener();
				plus.webview.close(preUrl,false);
			}
			setlange_obj(); //加载头部语言包
			var getSn = getQueryString("sn");
			app = new Vue({
				el: "#app",
				data: {
					name: "", //优惠券名称
					shop_name: "", //店铺名
					begin_time: "", //开始时间
					end_time: "", //结束时间
					id: "", //游客编码
					status: "", //优惠券核销是否成功
					discount: "", //折扣
					couponStatus: "", //优惠券状态
					content: "", //使用说明
					shop_list_name: "", //适用店铺
					type: "", //为1时满减，为2时为折扣
					amount: "", //满减金额
					condition: "", //使用条件
					username: "", //手机号；不为空时，是用户，否则为游客
					nickname: "", //昵称
					headimgurl: "", //用户头像
					b_lg: global_lange, //语言包
					is_vip: "", //是否是vip；为1时是VIP
					languageStyle:getItem("lg")
				},
				created: function() {
					this.init();
				},
				methods: {
					init: function() {
						common_ajax(1, {
							sn: getSn
						}, "get_coupon_info_bySn", function(res) { //根据动态码获取用户优惠券信息
							if(res.status == 1) {
								app.name = res.result.info.name;
								app.shop_name = res.result.info.shop_name;
								app.begin_time = res.result.info.begin_time;
								app.end_time = res.result.info.end_time;
								app.discount = res.result.info.discount;
								app.couponStatus = res.result.info.status;
								app.content = res.result.info.content;
								app.shop_list_name = res.result.info.shop_list_name;
								app.condition = res.result.info.condition;
								app.amount = res.result.info.amount;
								app.type = res.result.info.type;

								app.id = res.result.member_info.id;
								app.username = res.result.member_info.username;
								app.headimgurl = res.result.member_info.headimgurl;
								app.is_vip = res.result.member_info.is_vip;
								app.nickname = res.result.member_info.nickname;

							} else {
								mui.toast(res.msg);
							}

						})

					},
					cancelCoupon: function() {
						var btnArray2 = [app.b_lg[1049], app.b_lg[1008]];
						mui.confirm("确定核销该优惠券吗？", app.b_lg[1050], btnArray2, function(ee) {
							if(ee.index == 1) {
								//确定
								//跳转到扫码页
								common_ajax(1, {
									sn: getSn
								}, "put_coupon_use", function(res) { //优惠券核销
									if(res.status == 1) {
										app.status = res.status;
									} else {
										mui.toast(res.msg);
									}
								})
							} else {
								//取消
								app.init();
							}
						},"div")

					},
					hide: function() {
						$(".mask").hide();
						this.init();
					},
					gotoart: function(e) {
						clicked(e);
					},
					backpre: function() {
						if(getID == 1) {
							if(isAPP) {
								var preUrl = plus.webview.currentWebview().opener();
								preUrl.evalJS('refresh()')
							}
							com_back();
						} else {
							closepre();
						}
					}
				}
			})
		}
	</script>

</html>
